package SV_DATA_DB;

import javax.servlet.ServletRequest;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Example {
    public void setUserLastName(ServletRequest req, Connection con) throws SQLException {
        // Source of data from HTTP request in servlet
        String lastName = req.getParameter("lastName");
        int userId = Integer.parseInt(req.getParameter("userId"));

        String query = "UPDATE userData INTO lastName=? WHERE userid = ?";
        PreparedStatement statement = con.prepareStatement(query);
        statement.setString(1, lastName);
        statement.setInt(2, userId);
        statement.executeUpdate();
    }
}
